<?php

declare(strict_types=1);

namespace App\Service;

use App\Model\Adver as AdverModel;

class Adver extends BaseService
{
    // 分页列表
    public function list(array $map,int $page = 10)
    {
        return AdverModel::query()->where($map)->orderBy('sort', 'desc')->orderBy('id', 'desc')->paginate($page);
    }

    // 添加
    public function addAdver($data)
    {
        unset($data['id']);
        return AdverModel::insert($data);
    }

    // 编辑
    public function editAdver($id, $data)
    {
        print_r($data);
        return AdverModel::query()->where('id', $id)->update($data);
    }

    // 删除
    public function deleteAdver($id)
    {
        return AdverModel::where('id', $id)->delete();
    }
}
